package net.web.belerofont.controller;

import java.util.List;
import java.util.Map;

import net.web.belerofont.action.Action;
import net.web.belerofont.action.Interceptor;

import org.apache.log4j.Logger;

public abstract class ConfigReader {
	public static final Logger LOG = Logger.getLogger(ConfigReader.class);

	public abstract Map<String, Action> getActions();

	public abstract List<Interceptor> getGlobalInterceptors();

	public abstract List<Interceptor> getInterceptors(String actionPath);

	public abstract List<Interceptor> getLocalInterceptors(String actionPath);

	protected Action getActionByClassName(String name)
			throws ClassNotFoundException, InstantiationException,
			IllegalAccessException {
		Action local;

		Class actionClass = Class.forName(name);
		local = (Action) actionClass.newInstance();
		return local;
	}

	protected Interceptor getInterceptorByClassName(String name)
			throws ClassNotFoundException, InstantiationException,
			IllegalAccessException {
		Interceptor local;

		Class actionClass = Class.forName(name);
		local = (Interceptor) actionClass.newInstance();
		return local;
	}
}
